package com.sweet.fourtimeoa.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sweet.fourtimeoa.mapper.DesktopMapper;
import com.sweet.fourtimeoa.mapper.DocumentMapper;
import com.sweet.fourtimeoa.pojo.dto.*;
import com.sweet.fourtimeoa.pojo.entity.*;
import com.sweet.fourtimeoa.pojo.vo.*;
import com.sweet.fourtimeoa.service.DesktopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DesktopServiceImpl implements DesktopService {
    @Autowired
    private DesktopMapper desktopMapper;

    //我的便签-查询
    @Override
    public List<Notes> getNotesList(Integer userId) {
        return desktopMapper.getNotesList(userId);
    }
    //我的便签-添加
    @Override
    public boolean addNotes(Notes notes) {
        return desktopMapper.addNotes(notes);
    }
    //我的便签-删除
    @Override
    public boolean deleteNotes(Integer noteId) {
        return desktopMapper.deleteNotes(noteId);
    }
    //我的便签-修改
    @Override
    public boolean updateNotes(Notes notes) {
        return desktopMapper.updateNotes(notes);
    }



    //待处理任务-请假申请分页查询
    @Override
    public PageVo<LeaveApplicationsAndUsersVo> queryLeaveApplicationsAndUsersList(PageDto<LeaveApplicationsAndUsersDto> pageDto) {
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<LeaveApplicationsAndUsersVo> list =(Page<LeaveApplicationsAndUsersVo>) desktopMapper.queryLeaveApplicationsAndUsers(pageDto.getData());
        PageVo<LeaveApplicationsAndUsersVo> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }
    //待处理任务-出差申请分页查询
    @Override
    public PageVo<TravelApplicationsAndUsers> queryTravelApplicationsAndUsers(PageDto<TravelApplicationsAndUsersDto> pageDto) {
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<TravelApplicationsAndUsers> list =(Page<TravelApplicationsAndUsers>) desktopMapper.queryTravelApplicationsAndUsers(pageDto.getData());
        PageVo<TravelApplicationsAndUsers> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }
    //待处理任务-收入证明申请分页查询
    @Override
    public PageVo<IncomeProofApplicationsAndUsers> queryIncomeProofApplicationsAndUsers(PageDto<IncomeProofApplicationsAndUsersDto> pageDto) {
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<IncomeProofApplicationsAndUsers> list =(Page<IncomeProofApplicationsAndUsers>) desktopMapper.queryIncomeProofApplicationsAndUsers(pageDto.getData());
        PageVo<IncomeProofApplicationsAndUsers> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }
    //待处理任务-用车申请分页查询
    @Override
    public PageVo<VehicleUsageAndVehicleManagementAndUsers> queryVehicleUsageAndVehicleManagementAndUsers(PageDto<VehicleUsageAndVehicleManagementAndUsersDto> pageDto) {
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<VehicleUsageAndVehicleManagementAndUsers> list =(Page<VehicleUsageAndVehicleManagementAndUsers>) desktopMapper.queryVehicleUsageAndVehicleManagementAndUsers(pageDto.getData());
        PageVo<VehicleUsageAndVehicleManagementAndUsers> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }
    //待处理任务-用章申请分页查询
    @Override
    public PageVo<SealManagement> querySealManagement(PageDto<SealManagementDto> pageDto) {
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<SealManagement> list =(Page<SealManagement>) desktopMapper.querySealManagement(pageDto.getData());
        PageVo<SealManagement> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }
    //待处理任务-图书预约申请分页查询
    @Override
    public PageVo<BookBorrowing> queryBookBorrowing(PageDto<BookBorrowingDto> pageDto) {
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<BookBorrowing> list =(Page<BookBorrowing>) desktopMapper.queryBookBorrowing(pageDto.getData());
        PageVo<BookBorrowing> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }
    //待处理任务-名片打印申请分页查询
    @Override
    public PageVo<BusinessCardPrinting> queryBusinessCardPrinting(PageDto<BusinessCardPrintingDto> pageDto) {
        PageHelper.startPage(pageDto.getPageNum(), pageDto.getPageSize());
        Page<BusinessCardPrinting> list =(Page<BusinessCardPrinting>) desktopMapper.queryBusinessCardPrinting(pageDto.getData());
        PageVo<BusinessCardPrinting> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }










    //根据id修改申请状态
    //请假
    @Override
    public boolean UpdateStatusLeaveApplicationsAndUsersList(LeaveApplicationsAndUsersVo leaveApplicationsAndUsersVo) {
        return desktopMapper.UpdateStatusLeaveApplicationsAndUsersList(leaveApplicationsAndUsersVo);
    }





    //根据id查看对应显示的修改信息
    //请假
    @Override
    public LeaveApplicationsAndUsersVo LookUpdateLeaveApplicationsAndUsersList(Integer applicationId) {
        return desktopMapper.LookUpdateLeaveApplicationsAndUsersList(applicationId);
    }
    //出差
    @Override
    public TravelApplicationsAndUsers LookUpdateTravelApplicationsAndUsersList(Integer applicationId) {
        return desktopMapper.LookUpdateTravelApplicationsAndUsersList(applicationId);
    }
    //收入
    @Override
    public IncomeProofApplicationsAndUsers LookUpdateIncomeProofApplicationsAndUsersList(Integer applicationId) {
        return desktopMapper.LookUpdateIncomeProofApplicationsAndUsersList(applicationId);
    }
    //用车
    @Override
    public VehicleUsageAndVehicleManagementAndUsers LookUpdateVehicleUsageAndVehicleManagementAndUsers(Integer usageId) {
        return desktopMapper.LookUpdateVehicleUsageAndVehicleManagementAndUsers(usageId);
    }
    //用章
    @Override
    public SealManagement LookUpdateSealManagementList(Integer id) {
        return desktopMapper.LookUpdateSealManagementList(id);
    }
    //图书
    @Override
    public BookBorrowing LookUpdateBookBorrowingList(Integer id) {
        return desktopMapper.LookUpdateBookBorrowingList(id);
    }
    //名片
    @Override
    public BusinessCardPrinting LookUpdateBusinessCardPrintingList(Integer id) {
        return desktopMapper.LookUpdateBusinessCardPrintingList(id);
    }





    //通告管理-首页查询所有
    @Override
    public List<Announcements> getAnnouncementsList() {
        return desktopMapper.getAnnouncementsList();
    }

    //待处理任务-请假申请查询所有
    @Override
    public List<LeaveApplicationsAndUsersVo> getLeaveApplicationsAndUsersList() {
        return desktopMapper.getLeaveApplicationsAndUsersList();
    }
    //待处理任务-出差申请查询所有
    @Override
    public List<TravelApplicationsAndUsers> getTravelApplicationsAndUsersList() {
        return desktopMapper.getTravelApplicationsAndUsersList();
    }
    //待处理任务-收入证明流程查询所有
    @Override
    public List<IncomeProofApplicationsAndUsers> getIncomeProofApplicationsAndUsersList() {
        return desktopMapper.getIncomeProofApplicationsAndUsersList();
    }
    //待处理任务-用车申请查询所有
    @Override
    public List<VehicleUsageAndVehicleManagementAndUsers> getVehicleUsageAndVehicleManagementAndUsers() {
        return desktopMapper.getVehicleUsageAndVehicleManagementAndUsers();
    }
    //待处理任务-用章申请查询所有
    @Override
    public List<SealManagement> getSealManagementList() {
        return desktopMapper.getSealManagementList();
    }
    //待处理任务-图书申请查询所有
    @Override
    public List<BookBorrowing> getBookBorrowingList() {
        return desktopMapper.getBookBorrowingList();
    }
    //待处理任务-名片印制查询所有
    @Override
    public List<BusinessCardPrinting> getBusinessCardPrintingList() {
        return desktopMapper.getBusinessCardPrintingList();
    }




    //获取待处理数据个数
    //请假
    @Override
    public Integer countLeave() {
        return desktopMapper.countLeave();
    }
    //出差
    @Override
    public Integer countBusinessCar() {
        return desktopMapper.countBusinessCar();
    }
    //收入
    @Override
    public Integer countIncomeProof() {
        return desktopMapper.countIncomeProof();
    }
    //用车
    @Override
    public Integer countVehicleUsageAndVehicle() {
        return desktopMapper.countVehicleUsageAndVehicle();
    }
    //用章
    @Override
    public Integer countSealManagement() {
        return desktopMapper.countSeal();
    }
    //图书
    @Override
    public Integer countBookBorrowing() {
        return desktopMapper.countBook();
    }
    //名片
    @Override
    public Integer countT() {
        return desktopMapper.countT();
    }


}
